<?php
if(empty($output['address_list'])){
    appMessage('请添加收货地址','index.php?act=member_index&op=address_mod&is_order=1');
}
?>
<style>
    .dise a {background: url(<?php echo TEMPLATES_PATH;?>/images/public.png) no-repeat;width: 13px;height: 13px; position: relative; top:4px; margin-right:8px;}
    .dise a:link, .dise a:visited, .dise a:active {text-decoration: none;}
    .dise .decrease{background-position: 0px -60px;}
    .dise a:hover.decrease { background-position: -13px -60px}
    .dise .increase{background-position: -26px -60px;}
    .dise a:hover.increase { background-position: -39px -60px}
    .dise .text-hidden {line-height: 0;font-size: 0;overflow: hidden;}
    .dise .fl {float: left;display: inline;}
</style>
<header class="layout head padding-small">
    <a href="javascript:back(true);" class="hBack float-left"></a>
    <h4 class="hTxt float-left text-center text-white">订单确认</h4>
    <a href="javascript:;" id="btnJdkey" class="hHlep float-right"></a>
</header>
<form method="post" id="order_form" name="order_form" action="index.php?<?php if($output['buynow']){ echo 'act=order&op=save_buynow_order&p=app';}else{echo 'act=order&op=save_cart_order&p=app';} ?>">
    <?php if($_REQUEST['brand_id']){?>
        <input name="brand_id" value="<?php echo $_REQUEST['brand_id'];?>" type="hidden"/>
    <?php }?>
    <?php if($output['buynow']){?>
        <input type="hidden" name="buynow_spec_id" value="<?php echo $_GET['buynow_spec_id']; ?>" />
        <input type="hidden" name="buynow_quantity" value="<?php echo $_GET['buynow_quantity']; ?>" />
    <?php } ?>
    <?php if(is_array($_GET['store_id'])){  ?>
        <?php foreach ($_GET['store_id'] as $key => $value) { ?>
            <input type="hidden" name="store_id[]" value="<?php echo $value; ?>" />
	   <?php if($value == OFFICIAL_STORE_ID){?>
            <input type="hidden" name="official_shop" value="1" />
            <?php }?>
        <?php } ?>
    <?php }else{ ?>
        <input type="hidden" name="store_id[]" value="<?php echo intval($_GET['store_id']); ?>" />
	<?php if($_GET['store_id'] == OFFICIAL_STORE_ID){?>
        <input type="hidden" name="official_shop" value="1" />
        <?php }?>
    <?php } ?>

    <input type="hidden" id="address_options" name="address_options" value='<?php echo $output['address_list'][0]['address_id'];?>'/>
    <input type="hidden" id="city_id" name="city_id" value='<?php echo $output['address_list'][0]['city_id'];?>'/>

<div class="goodsOrder-con">
    <!--收货信息S-->
    <div class="goods-receivinInformation radius-big bg-white padding margin height">
        <div class="clearfix">
            <i class="gri-icon float-left"></i>
            <span class="margin-left">收货信息</span>
        </div>
        <hr>
        <!--默认收货地址S-->
        <div class="gri-con">
            <?php foreach((array)$output['address_list'] as $k=>$val){ ?>
                <div>
                    <span class="gri-userName padding-right"><?php echo $val['true_name']; ?></span>
                    <span class="gri-mobile"><?php if($val['mob_phone']) echo $val['mob_phone']; else echo $val['tel_phone']; ?></span>
                    <i class="float-right icon-angle-right"></i>
                </div>
                <div class="address text-small"><?php echo $val['area_info']; ?>&nbsp;&nbsp;<?php echo $val['address']; ?></div>
            <?php break;} ?>
        </div>
    </div>
    <!--默认收货地址E-->
    <!--商品信息S-->
    <div class="bg-white  margin-top padding radius-big">确认购物清单：</div>
         <?php if (!empty($output['cart_goods_list']) && is_array($output['cart_goods_list'])) { ?>
        <?php foreach ($output['cart_goods_list'] as $cart_store_id => $cart_store_goods_list) { ?>
        <div class="goods-information radius-big bg-white padding margin-bottom form-group">
            <!--商城S-->
            <div class="sale-off clearfix">
                <i class="sale-icon float-left margin-left"></i>
            <?php if ($cart_store_id == JKY_STORE_ID) { ?>
                <span class="margin-left"><a url="index.php?act=activity" onClick="pclicked(this);"><?php echo $output['cart_info_list'][$cart_store_id]['store_name']; ?></a></span>
            <?php }elseif($cart_store_id == OFFICIAL_STORE_ID) { ?>
                <span class="margin-left"><a url="index.php?act=official_shop" onClick="pclicked(this);"><?php echo $output['cart_info_list'][$cart_store_id]['store_name']; ?></a></span>
            <?php }else{ ?>
                <span class="margin-left"><a url="<?php echo ncUrl(array('act' => 'show_store', 'id' => $cart_store_id), 'store', $output['cart_info_list'][$cart_store_id]['store_domain']); ?>" onClick="pclicked(this);"><?php echo $output['cart_info_list'][$cart_store_id]['store_name']; ?></a></span><?php } ?>
                <?php if($output['cart_info_list'][$cart_store_id]['store_mdt_status']==STORE_MDT_STATUS_PASS) echo "【美达通服务】";?>
            </div>
            <!--商城E-->
            <?php foreach ( $cart_store_goods_list as $cart_id => $cart_store_goods_row) { ?>
            <div>
                <div class="clearfix">
                    <a url="<?php echo ncUrl(array('act' => 'goods', 'goods_id' => $cart_store_goods_row['goods_id']), 'goods'); ?>" class="goods-img float-left" onClick="pclicked(this);"><img src="<?php echo thumb($cart_store_goods_row, 'small'); ?>" onerror="this.src='<?php echo TEMPLATES_PATH;?>/images/touch2013/no_100_100.jpg'" class="good-img"></a>
                    <a url="<?php echo ncUrl(array('act' => 'goods', 'goods_id' => $cart_store_goods_row['goods_id']), 'goods'); ?>" class="goods-name text-small" onClick="pclicked(this);"><?php echo $cart_store_goods_row['goods_name']; ?></a>
                </div>
                <div class="padding-top padding-left clearfix">
                    <span class="goods-price text-red float-left padding-right">&yen;<span><?php echo $cart_store_goods_row['spec_goods_price']; ?></span>&nbsp;&nbsp;x</span>
                        <span class="numWrite inlineBlock float-left" ><?php echo $cart_store_goods_row['goods_num']; ?></span>
                    <span class="float-right text-red">&yen;<?php echo $cart_store_goods_row['goods_all_price']; ?></span>
                    <?php  if ($cart_store_goods_row['goods_transfee_charge']==0){ ?>
                        <select  id="transport_type[<?php echo intval($cart_store_id);?>][<?php echo $cart_store_goods_row['spec_id'];?>]" name="transport_type[<?php echo intval($cart_store_id);?>][<?php echo $cart_store_goods_row['spec_id'];?>]" specid="<?php echo $cart_store_goods_row['spec_id'];?>" class="transport_type_dropdownlist margin-left " data-selectstoreid="<?php echo intval($cart_store_id);?>"></select>
                        <span data-textstoreid="<?php echo intval($cart_store_id);?>"></span>
                    <?php }else{ ?>
                        <!--                        <span>卖家承担运费</span>-->
                        <?php if($cart_store_goods_row['is_transport_dajian']==1){?>
                            <span class="margin-left float-left">运费到付</span>
                        <?php }?>
                    <?php }?>

                </div>
            </div>
                <?php }?>

            <div class="sale-price">总价（含运费）：<span class="text-red text-big store_goods_price_amount_text" id="store_goods_price_amount_<?php echo $cart_store_id; ?>" data-storeid="<?php echo $cart_store_id; ?>">&yen;<?php echo $output['cart_goods_amount_list'][$cart_store_id];?></span>&nbsp;&nbsp;运费：<span class="text-red text-big store_transport_fee_amount_text" id="store_transport_fee_amount_<?php echo $cart_store_id; ?>" data-storeid="<?php echo $cart_store_id; ?>"> &yen;<?php echo $output['cart_transport_fee_amount_list'][$cart_store_id];?></span></div>

<!--货到付款-->
            <?php if(in_array($cart_store_id,array(OFFICIAL_STORE_ID,JKY_STORE_ID)) || !empty($_REQUEST['brand_id'])){?>
            <div class="field cod-box_<?php echo $cart_store_id;?>"><img src="<?php echo TEMPLATES_PATH;?>/images/cart/hdfk.gif" />：
                <label for="order_cod_<?php echo $cart_store_id; ?>_0"><input type="radio"  name="order_cod[<?php echo $cart_store_id; ?>]" id="order_cod_<?php echo $cart_store_id; ?>_0" value="0" class="ordercod"> 否</label>
                <label for="order_cod_<?php echo $cart_store_id; ?>_1"><input type="radio" name="order_cod[<?php echo $cart_store_id; ?>]" id="order_cod_<?php echo $cart_store_id; ?>_1"  value="1" checked="true" class="margin-large-left border-ef7f7e ordercod"> 是</label>
            </div>
                <?php }?>
            <?php if($cart_store_id==OFFICIAL_STORE_ID){?>
                <div class="field coupon-box"><img src="<?php echo TEMPLATES_PATH;?>/images/cart/yhj.gif" />：
                    <label for="order_coupon_<?php echo $cart_store_id; ?>_0"><input type="radio"  name="order_coupon[<?php echo $cart_store_id; ?>]" id="order_coupon_<?php echo $cart_store_id; ?>_0" value="0" class="ordercoupon"> 否</label>
                    <label for="order_coupon_<?php echo $cart_store_id; ?>_1"><input type="radio" name="order_coupon[<?php echo $cart_store_id; ?>]" id="order_coupon_<?php echo $cart_store_id; ?>_1"  value="1" checked class="margin-large-left border-ef7f7e ordercoupon"> 是</label>
                    <div class="coupon-box"> 使用优惠券立省 <span class="text-dot">&yen; <?php echo COUPON_MONEY;?> </span></div>
                </div>
            <?php }?>

            <!--现金券-->
            <?php if(in_array($cart_store_id,array(OFFICIAL_STORE_ID))){?>
                    <div class="field xjq-box_<?php echo $cart_store_id;?>"><span class="text-big text-dot">现金券：</span>&nbsp;&nbsp;
                        <label for="order_xjq_<?php echo $cart_store_id; ?>_0">
                            <input type="radio"  class="orderxjq" name="order_xjq[<?php echo $cart_store_id; ?>]" id="order_xjq_<?php echo $cart_store_id; ?>_0" value="0"> 否</label>
                        <label for="order_xjq_<?php echo $cart_store_id; ?>_1">
                            <input type="radio" name="order_xjq[<?php echo $cart_store_id; ?>]"  id="order_xjq_<?php echo $cart_store_id; ?>_1" value="1" checked="true" class="margin-large-left border-ef7f7e orderxjq"> 是</label>
                    </div>
                <?php }?>

            <?php  if($output['cart_store_mansong_explain_list'][$cart_store_id]) { ?>
                <div class=" goods-activity">
                    <?php echo $output['cart_store_mansong_explain_list'][$cart_store_id]; ?>
                </div>
            <?php  } elseif(($output['cart_voucher_list'][$cart_store_id]['xianshi_flag'] == false) && ($output['cart_voucher_list'][$cart_store_id]['mansong_flag'] == false) && ($output['cart_voucher_list'][$cart_store_id]['bundling_flag'] == false)) { ?>
            <?php if (C('voucher_allow') == 1) { ?>
                    <dl>
                        <dt>选择代金券：<i></i></dt>
                        <dd>
                            <?php if(empty($output['cart_voucher_list'][$cart_store_id])) {?>
                                <div>无可用代金券 <span class="money" nc_type="shipping_fee" value="0">0.00</span> </div>
                            <?php } else { ?>
                                <div class="voucheritem">
                                    <label for="vouch_cod_<?php echo $cart_store_id; ?>">
                                        <input type="radio" value="0" id="vouch_cod_<?php echo $cart_store_id; ?>" name="voucher_id[<?php echo $cart_store_id; ?>]" rel="voucher" checked>
                                        不使用
                                    </label>
                                </div>
                                <?php  foreach($output['cart_voucher_list'][$cart_store_id] as $voucher) { ?>
                                    <div  class="voucheritem" title="订单满<?php echo $voucher['voucher_limit'];?>元 代金券：<?php echo $voucher['voucher_code'];?>">
                                        <label for="voucher_id_<?php echo $voucher['voucher_id']; ?>">
                                            <input type="radio" id="voucher_id_<?php echo $voucher['voucher_id'];?>" value="<?php echo $voucher['voucher_id'];?>" name="voucher_id[<?php echo $cart_store_id; ?>]" rel="voucher">
                                            使用代金券立省
                                                          <span class="cart-goods-price" nc_type="shipping_fee" value="<?php echo $voucher['voucher_price'];?>">
                                                              &yen;<?php echo ncPriceFormat($voucher['voucher_price']);?>
                                                          </span>&nbsp;
                                            (<?php echo $voucher['voucher_desc'];?>)
                                        </label>
                                    </div>
                                <?php } ?>
                            <?php  } ?>
                        </dd>
                    </dl>
                <?php } ?>
            <?php  }?>
            
	   <?php if(in_array($cart_store_id,array(OFFICIAL_STORE_ID)) ){?>
            <div class="field spread-box_<?php echo $cart_store_id;?>" style=" padding: 5px 0; color: #F00; height: 40px;">
                    <div style="float:left;">
                        <label for="spread-num-box">
                        <span style="float: left;">使用推广券&nbsp;&nbsp;</span>
                      <span class="dise">
                      <a href="javascript:void(0)" class="decrease fl text-hidden">-</a>
                      <input name="spread_num" size="5" type="text" value="<?php echo (int)$output['cart_spread_num_list'][$cart_store_id];?>" style="float:left; margin-right:8px;" />
                      <a href="javascript:void(0)" class="increase fl text-hidden">+</a>
                      </span>
                        张
                        </label>
                    </div>
                </div>
            </div>
            <?php } ?>
            
            <?php if(!1){?>
                <span style=" display:block; line-height:20px; height:20px; font-size:14px; margin-top:5px;">运费险
                  <span style="color:#F00;"> (&yen; <?php echo TRANS_INSURANCE_COST;?>)</span>
                  : <input type="checkbox" class="safenum" name="safe[<?php echo $cart_store_id; ?>]"  value="1" style="width:16px; height:16px;"> 购买退货运费险，退货可赔付8元
                  </span>
            <?php }?>

            <div class="">
                <div class="margin-small-bottom">补充说明</div>
                <div class="border border-ef7f7e radius-big ">
                    <input type="text" class="border-none padding-small text-small height radius-big layout postscript_input" data-storeid="<?php echo $cart_store_id; ?>" maxlength="200" placeholder="选填,填写您对商品的特殊需求，如颜色、尺码等">
                </div>
            </div>
        </div>
        <?php }?>
        <?php }?>
    <div class="bg-white padding">
        <?php if($_GET['store_id']!='31'){ ?>
            <div class="price">应付金额：&yen; <em id="order_amount"></em></div>
        <?php } ?>
        <div class="address">寄送至：<em id="confirm_address"></em></div>
        <div class="buyer">收货人：<em id="confirm_buyer"></em></div>
    </div>
        <div class="padding text-center clearfix">
            <a url="index.php?act=cart" class="x5 padding bg-red text-white radius-big " onClick="pclicked(this);">返回进货车</a>
            <a href="javascript:void(0);" onclick="formSubmit();" class="x5 padding float-right bg-red text-white radius-big ">下单完成并支付</a>
        </div>
</div>
    <input type="hidden" id="trans_sum" name="trans_sum" value="<?php echo $output['cart_order_amount'];?>">
    <input id="store_goods_price" type="hidden" value="<?php echo number_format($output['store_goods_price'],2);?>" />
</form>

<div id="dataLoading" class="text-center text-dot  text-white" style="position:absolute;display: none; background:rgba(0,0,0,0.75); padding: 20px 40px; filter: alpha(opacity=75); -moz-opacity: 0.75; opacity: .75;">
    金额计算中...
</div>

<!--地址列表-->
<div class="receivinInformation margin">
    <div class="bg-white height-big radius-big text-center ">选择收货地址</div>
    <?php foreach((array)$output['address_list'] as $k=>$val){ ?>
    <div class="gri-con-list bg-white padding height radius-big" data-city_id="<?php echo $val['city_id']?>" data-address_id="<?php echo $val['address_id']; ?>" address="<?php echo $val['area_info']; ?>&nbsp;&nbsp;<?php echo htmlspecialchars($val['address']); ?>" buyer="<?php echo $val['true_name']; ?>&nbsp;&nbsp;<?php if($val['mob_phone']) echo $val['mob_phone']; else echo $val['tel_phone']; ?>">
        <div>
            <span class="gri-userName padding-right"><?php echo $val['true_name']; ?></span>
            <span class="gri-mobile"><?php if($val['mob_phone']) echo $val['mob_phone']; else echo $val['tel_phone']; ?></span>
            <i class="float-right text-big text-ef7f7e <?php if($k==0){?>icon-check-circle-o<?php }?> addressCheck"></i>
        </div>
        <div class="address text-small"> <?php echo $val['area_info']; ?>&nbsp;&nbsp;<?php echo $val['address']; ?></div>
    </div>
    <?php }?>

    <a url="index.php?act=member_index&op=address_mod&is_order=1" class="text-red margin-top layout text-center bg-white padding height radius-big" onClick="pclicked(this);">+添加收货地址</a>
</div>
<script type="text/javascript">
    function formSubmit(){
        var url = $('#order_form').attr('action');
        $.post('<?php echo SiteUrl;?>/app/'+url,$("form#order_form").serialize(),function(data){
            Jump(data);
        },'json');
    }

    (function(){
            //默认地址为最新添加的地址
            $('#confirm_address').html($('.gri-con .address').html());
            $('#confirm_buyer').html($('.gri-con .gri-userName').html()+$('.gri-con .gri-mobile').html());

        //地址选择事件
        var $receivinInformation = $('.receivinInformation'),
            $goodsOrderCon = $('.goodsOrder-con') ;
        $('.gri-con').click(function(){
            $goodsOrderCon.hide();
            $receivinInformation.show();
        })
        $('.gri-con-list').click(function(){
            var $aChecked = $(this).find('.addressCheck'),
                $aNOChecked = $(this).siblings().find('.addressCheck'),
                a = $(this).find('.gri-userName').text(),
                b = $(this).find('.gri-mobile').text(),
                c = $(this).find('.address').text();
            $aNOChecked.removeClass('icon-check-circle-o');
            $aChecked.addClass('icon-check-circle-o');
            $receivinInformation.hide();
            $goodsOrderCon.show();
            $('.gri-con .gri-userName').text(a);
            $('.gri-con .gri-mobile').text(b);
            $('.gri-con .address').text(c);
            //地址隐藏域的值
            $("#address_options").val($(this).data('address_id'));
            $("#city_id").val($(this).data('city_id'));
            loadTransportOptions();
            $('#confirm_address').html($(this).attr('address'));
            $('#confirm_buyer').html($(this).attr('buyer'));

        })

        //运费计算
        loadTransportOptions=function (){
            var url = 'index.php?act=order&op=getTransportOptions&rand='+Math.random();
            var specDataList=new Array();
            $('.transport_type_dropdownlist').each(function(index, element) {
                specDataList.push($(this).attr('specid'));
            });
            $.post(url,{specPostData:specDataList.join(','),city_id:$("#city_id").val()},function(response){
                var ret=$.parseJSON(response);
                $.each(ret,function(index,val){
                    $('select[specid='+index+']').html(val);
                });
                loadAllPrice();
            });
        };
        //ajax加载效果,显示计算中..
        var dataload=function(){
            if(!$('#dataLoading').is(':visible')){
                $('#dataLoading').show();
                $(window).bind('resize scroll',function(){
                    $('#dataLoading').css({
                        left: ($(window).width() - $('#dataLoading').outerWidth())/2+ $(document).scrollLeft(),
                        top: ($(window).height() - $('#dataLoading').outerHeight())/2+ $(document).scrollTop()
                    });
                });
                $('#dataLoading').css({
                    left: ($(window).width() - $('#dataLoading').outerWidth())/2+ $(document).scrollLeft(),
                    top: ($(window).height() - $('#dataLoading').outerHeight())/2+ $(document).scrollTop()
                });
            }
        };
        dataload();

        loadAllPrice=function(){
            dataload();
            var url = 'index.php?act=order&op=calc_cart_amount<?php if($_REQUEST['brand_id']){echo '&brand_id='.$_REQUEST['brand_id'];}?>&city_id='+$("#city_id").val()+'&rand='+Math.random();
            <?php if($output['buynow']){?>
             url = 'index.php?act=order&op=calc_buynow_amount&buynow_spec_id=<?php echo $_GET['buynow_spec_id'];?>&buynow_quantity=<?php echo $_GET['buynow_quantity'];?>&city_id='+$("#city_id").val()+'&rand='+Math.random();
            <?php } ?>
            var specDataList=new Array();
            $('.transport_type_dropdownlist').each(function(index, element) {
                specDataList.push($(this).attr('specid'));
            });
            $.post(url,$('#order_form').serialize(),function(response){
                var data=$.parseJSON(response);
                for(var storeid in data['StoreCodEnableList']){
				if(storeid==<?php echo OFFICIAL_STORE_ID;?>){
					if($('input[name=spread_num]').val()!=data['StoreSpreadNumList'][<?php echo OFFICIAL_STORE_ID; ?>]){
						$('input[name=spread_num]').val(data['StoreSpreadNumList'][<?php echo OFFICIAL_STORE_ID; ?>]);
					}
				}
                    if(storeid==<?php echo OFFICIAL_STORE_ID;?>){
                        if( typeof(data['StoreCodEnableList'][storeid])!="undefined"){
                            if(data['StoreCodEnableList'][storeid]){
                                $('.cod-box_'+storeid).show();
                            }else{
                                $('.cod-box_'+storeid).hide();
                                $('#order_cod_<?php echo OFFICIAL_STORE_ID; ?>_0').attr('checked',true);
                                $('#order_cod_<?php echo OFFICIAL_STORE_ID; ?>_1').removeAttr('checked');
                            }
                        }
                    }
                    if(storeid==<?php echo OFFICIAL_STORE_ID;?>){
                        if( typeof(data['StoreXjqEnableList'][storeid])!="undefined"){
                            if(data['StoreXjqEnableList'][storeid]){
                                $('.xjq-box_'+storeid).show();
                            }else{
                                $('.xjq-box_'+storeid).hide();
                                $('#order_xjq_<?php echo OFFICIAL_STORE_ID; ?>_0').removeAttr('checked');
                                $('#order_xjq_<?php echo OFFICIAL_STORE_ID; ?>_1').attr('checked',true);
                            }
                        }
                    }
                    if(storeid==<?php echo JKY_STORE_ID;?>){
                        if( typeof(data['StoreCodEnableList'][storeid])!="undefined"){
                            if(data['StoreCodEnableList'][storeid]){
                                $('.cod-box_'+storeid).show();
                            }else{
                                $('.cod-box_'+storeid).hide();
                                $('#order_cod_<?php echo JKY_STORE_ID; ?>_0').attr('checked',true);
                                $('#order_cod_<?php echo JKY_STORE_ID; ?>_1').removeAttr('checked');
                            }
                        }
                    }
                }
                for(var storeid in data['StoreCouponEnableList']){
                    if(storeid==<?php echo OFFICIAL_STORE_ID;?>){
                        if( typeof(data['StoreCouponEnableList'][storeid])!="undefined"){
                            if(data['StoreCouponEnableList'][storeid]){
                                $('.coupon-box').show();
                            }else{
                                $('.coupon-box').hide();
                                $('#order_coupon_<?php echo OFFICIAL_STORE_ID; ?>_0').attr('checked',true);
                                $('#order_coupon_<?php echo OFFICIAL_STORE_ID; ?>_1').removeAttr('checked');
                            }
                        }
                    }
                }
                $.post(url,$('#order_form').serialize(),function(response){
                    $('#dataLoading').fadeOut();
                    var data=$.parseJSON(response);
                    $('#trans_sum').val(data['StoreTransportFeeAmount']);

                    var insurace_cost=<?php echo TRANS_INSURANCE_COST;?>;
                    var insurace_amount=0;
                    $('.safenum').each(function(index, element) {
                        if($(this).attr('checked')){
                            insurace_amount+=insurace_cost;
                        }
                    });
                    var allmount=data['StoreOrderAmount']+insurace_amount;
                    $('#order_amount').html(number_format(allmount,2));


                    $('.store_goods_price_amount_text').each(function(index, element) {
                        if( typeof(data['StoreOrderAmountList'][$(this).attr('data-storeid')])!="undefined"){
                            $(this).html('&yen;'+data['StoreOrderAmountList'][$(this).attr('data-storeid')]);
                        }
                    });
                    $('.store_transport_fee_amount_text').each(function(index, element) {
                        if( typeof(data['StoreOrderAmountList'][$(this).attr('data-storeid')])!="undefined"){
                            $(this).html('&yen;'+data['StoreTransportFeeList'][$(this).attr('data-storeid')]);
                        }
                    });

                    for(var storeid in data['StoreShippingModeList']){
                        if( typeof(data['StoreShippingModeList'][storeid])!="undefined"){
                            if(data['StoreShippingModeList'][storeid]==<?php echo SHIPPING_MODE_FDY;?>){
                                $('span[data-textstoreid='+storeid+']').html('统一配送');
                                $('select[data-selectstoreid='+storeid+']').hide();
                            }else if(data['StoreShippingModeList'][storeid]==<?php echo SHIPPING_MODE_MDT;?>){
                                $('span[data-textstoreid='+storeid+']').html('美达通运费');
                                $('select[data-selectstoreid='+storeid+']').hide();
                            }else if(data['StoreShippingModeList'][storeid]==<?php echo SHIPPING_MODE_DEFAULT;?>){
                                $('span[data-textstoreid='+storeid+']').html('');
                                $('select[data-selectstoreid='+storeid+']').show();
                            }else if(data['StoreShippingModeList'][storeid]==<?php echo SHIPPING_MODE_JKY;?>){
                                $('select[data-selectstoreid='+storeid+']').show();
                            }
                        }
                    }
		    codToggle();
                });
            });
        };
	//计算总金额
	function getallprice(){
		var order_amount = 0;
		<?php if(!$output['rule_shipping_free']) { ?>
		if ($('#trans_sum').val() != ''){
			order_amount += parseFloat($('#trans_sum').val());
		}
		<?php } ?>
		order_amount += parseFloat($("#store_goods_price").val());
		var voucher = parseFloat($(".selected_voucher").children(".pay").children(".money").attr('value'));
		if(voucher > 0){
			order_amount = order_amount - voucher;
		}
		
		$('#order_amount').html(number_format(order_amount,2));
	}

        $(document).ready(function(e) {
            $('.postscript_input').live('click',function(data){
                if(!$(this).attr('name')){
                    $(this).attr('name','order_message['+$(this).attr('data-storeid')+']');
                    $(this).val('');
                }
            });

            $('.transport_type_dropdownlist').live('change',function (data){
                loadAllPrice();
            });

            $('.ordercod').live('click',function (data){
                loadAllPrice();
            });
            $('.orderxjq').live('click',function (data){
                loadAllPrice();
            });
            $('.ordercoupon').live('click',function (data){
                loadAllPrice();
            });
            $('.safenum').click(function() {
                var precision=1000000000000;//精度处理,用于parseFloat精度不准问题
                if (this.checked) {
                    var ee=parseFloat($('#order_amount').text())*precision;
                    ee+=<?php echo TRANS_INSURANCE_COST;?>*precision;
                    ee=ee/precision;
                    ee=number_format(ee,2);
                    $('#order_amount').text(ee);
                }else{
                    var ee=parseFloat($('#order_amount').text())*precision;
                    ee-=<?php echo TRANS_INSURANCE_COST;?>*precision;
                    ee=ee/precision;
                    ee=number_format(ee,2);
                    $('#order_amount').text(ee);
                }
            });

            loadTransportOptions();

            //当选择代金券重新计算应付金额
            $('.voucheritem').live('click',function(){
                $(this).find("input[name='voucher_id']").attr('checked',true);
                $('.voucheritem').removeClass('selected_voucher');
                $(this).addClass('selected_voucher');
                loadAllPrice();
            });
		$('input[name=spread_num]').live('keyup',function(data){
			loadAllPrice();
		});
    });
    
    //大件商品货到付款隐藏
    function codToggle(){
        if($('input[name=official_shop]').val() > 0 || $('input[name=buynow_spec_id]').val() > 0){
            var spec_id = $('input[name=buynow_spec_id]').val(); 
            $.getJSON('index.php?act=order&op=ajaxGetCodState',{spec_id : spec_id},function(res){
                if(res.rs > 0){
                    $('.cod-box_<?php echo OFFICIAL_STORE_ID?>').hide();
                }
            })
        }
    }
    
    codToggle();
    })();
</script>
<script>
    $(function(){
        //点击-  商品数量
        $('.decrease').click(function(){                       //点击 -
            var Last_num = $('input[name=spread_num]').val();
            if(Last_num==0){
                $('input[name=spread_num]').val(Last_num);
            }else{
                $('input[name=spread_num]').val(Number(Last_num) -1);
            }
            loadAllPrice();
        });
        //点击+  商品数量
        $('.increase').click(function(){            //点击 +
            var Last_num = $('input[name=spread_num]').val();
            $('input[name=spread_num]').val(Number(Last_num) +1);
            current_num =Number(Last_num) +1;
            loadAllPrice();
        });
    });
</script>